<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	
  </head>
  
  <body>
    <div class="easyui-layout" fit="true">
		<!-- 表格上的toolbar工具条 -->
		<div id="easyui_toolbar" region="north" border="true" style="border-bottom:1px solid #999;height:32px;">
			<div style="height:5px; width:100%;"></div>
			<div style="height:10px;width:620px;float:left;"></div>
        	<input class="easyui-searchbox" data-options="prompt:'请输入查询条件...',menu:'#mm',searcher:searchCust" style="width:300px"></input>
			<div id="mm">
				<div data-options="name:'mohu',iconCls:'icon-ok'">昵称模糊查找</div>
				<div data-options="name:'jingque'">账号精确查找</div>
				<div data-options="name:'uid'">用户编号精确查找</div>
				<div data-options="name:'qq'">QQ号精确查找</div>
			</div>
        	
		</div>
		<!-- 表格数据区域 -->
		
		<div region="center" border="false" data-optinos:"fit:true;" style="">
			<table id="custtable">
			
			</table>
		</div>
	</div>
	
	<!-- 头像展示， 更改头像-->
	<div id="UimageDialog" class="easyui-dialog" title="商品图片" style="width:400px;height:400px;"
			data-options="iconCls:'pag-list',modal:true,closable:false,collapsible:false,minimizable:false,maximizable:false,resizable:false,closed:true">
		<div style="margin-left:5px;margin-right:5px;margin-top:5px;">
			<form name="fphotoform">
				<input type="hidden" id="uid" name="uid" value=""/>
				<table style="margin-top:20px; margin-left:20px;margin-right:20px;vertical-align:middle;" width="80%" border="0" cellpadding="0" cellspacing="1">
					<tr>
						<td style="width:20%; text-align:center;">
							<div id="imgdiv">
								<img id="uimage" name="uimage" width="220" height="220"/>
							</div>
						</td>	
					</tr>
					<tr>
						<td>
							<br/>
							<input type="file" name="up_img" id="up_img"/>
						</td>
					</tr>
				</table>
			</form>
			<div style="text-align:right;margin-right:30px;">
				<a href="javascript:updateUimage()" class="easyui-linkbutton" data-options="iconCls:'icon-ok'">确定</a>
				<a href="javascript:yhj_cancel('UimageDialog')" class="easyui-linkbutton" data-options="iconCls:'icon-undo'">取消</a>
			</div>
		</div>
	</div>
	
	
	
	<script>
		function updateUimage(){
			if($("#up_img").val()==""){
				//alert("不能插入空图片");
				showinfobox(1,"","不能插入空图片");
				return ;
			}
			$.ajaxFileUpload({
				url:"backadmin/file.action",//这个action主要用来接收上传的文件
				secureuri:false,//上传的时候是否使用安全协议https而不用http
				type:"POST",
				dataType:"JSON",
				fileElementId:"up_img",//上传文件域的id
				data:{op:'userheadimage',uid:$("#").val(),addrDir:'/headphotos'},
				success:function(data){
					if(data!=""){
						$("#UimageDialog").window("close");
						//$('#UimageDialog').datagrid('load'); 
						searchCust("","");
						showinfobox(1,"","修改成功...");
					}else{
						//失败了
						showinfobox(1,"","修改失败...");
					}
				}
			});
		}
		function yhj_cancel(name){
			$("#uimage").removeAttr("src");
			$("#up_img").val("");
			$("#UimageDialog").window("close");
		}
		function changeheadimg(uid,uimage){
			//alert(uid+"\t"+uimage);
			//1,0001.jpg
			new uploadPreview({ UpBtn: "up_img", DivShow: "imgdiv", ImgShow: "uimage" });
			if(uimage!="undefinde"){
				$("#uimage").attr("src","images/headphotos/"+uimage);
			}else{
				$("#uimage").attr("src","images/yhj_upload.png");
			}
			$("#uid").val(uid);
			$("#UimageDialog").window("open");
		}
		
	
		function searchCust(value,name){
			$("#custtable").edatagrid({
				url:'backadmin/user.action?op=findAllCust',
				saveUrl:'backadmin/user.action?op=saveCust',
				updateUrl:'backadmin/user.action?op=editCust',
				idField:"uid",
				pagination:true,
				pageNumber:1,
				pageSize:10,
				pageList:[10,20,120,40,50],
				fit:true,
				rownumbers:true,
				singleSelect:true,//表示可以单行选择
				title:"客户信息列表",
				sortName:"uid",
				sortOrder:"asc",
				queryParams: {
					searchOptions:value,
					seacherType:name
				},
				columns:[[  
				          {field:'uid',title:'用户编号',width:75,align:'center'}, 
				          {field:'uimage',title:'用户头像',width:60,align:'center',
				        	  formatter: function(value,rec){
				        			return '<img class="editCls1" src="images/mixedPicData/'+value+'" width="50" height="50" href="javascript:void(0)" onclick="changeheadimg(\''+rec.uid+'\',\''+value+'\')"/>';
				        	  }
					  	  },
				          {field:'ulogon',title:'用户名',width:140,editor:'text',align:'center'},  
				          {field:'upwd',title:'密码',width:120,align:'center',editor:'text',
				        	  formatter: function(value,row,index){
					  				return "**********";
					  			}
				          },
				          {field:'ualais',title:'昵称',width:100,editor:'text',align:'center'},
				          {field:'usex',title:'性别',width:75,align:'center'},
				          {field:'uname',title:'真实姓名',width:75,align:'center'},
				          {field:'sid',title:'主题',width:100,align:'center'},
				          {field:'uqq',title:'QQ',width:120,align:'center'},
				          {field:'ucname',title:'学校',width:120,align:'center'},
				          {field:'ucpro',title:'专业',width:120,align:'center'},
				          {field:'uclass',title:'班级',width:120,align:'center'},
				          {field:'utel',title:'联系方式',width:120,align:'center'},
				          {field:'uinfo',title:'个人简介',width:75,align:'center',
				        	formatter:function(value,rec){
				        		var f = '<a class="editCls2" href="javascript:void(0)" onclick="editUserDetail(\''+rec.uid+'\')">查看详情</a> ';
								return f;
				        	}  
				          },
				          {field:'udatetime',title:'注册时间',width:140,align:'center'},
				          {field:'ustatus',title:'状态',width:120,align:'center',
				        	  formatter:function(value){
				        		  if(value==0){
				        			  return "离线";
				        		  }else if(value==1){
				        			  return "在线";
				        		  }else if (value==2){
				        			  return "用户未激活";
				        		  }
				        	  }
				          },
				          {field:'uwealth',title:'财富值',width:120,align:'center',editor:'text'},
				          {field:'urank',title:'用户等级',width:120,align:'center',editor:'text'},
				          {field:'uvip',title:'VIP等级',width:120,align:'center',editor:'text'},
				          {field:'uglory',title:'称号',width:120,align:'center',editor:'text'},
				          {field:'ulike',title:'关心列表',width:120,align:'center',
					        	formatter:function(value,rec){
					        		var f = '<a class="editCls2" href="javascript:void(0)" onclick="editUserDetail(\''+rec.uid+'\')">查看详情</a> ';
									return f;
					        	}
				          },
				          {field:'uhabit',title:'操作习惯列表',width:120,align:'center',
					        	formatter:function(value,rec){
					        		var f = '<a class="editCls2" href="javascript:void(0)" onclick="editUserDetail(\''+rec.uid+'\')">查看详情</a> ';
									return f;
					        	}
				          },
				          {field:'ushieldid',title:'屏蔽列表',width:120,align:'center',
					        	formatter:function(value,rec){
					        		var f = '<a class="editCls2" href="javascript:void(0)" onclick="editUserDetail(\''+rec.uid+'\')">查看详情</a> ';
									return f;
					        	}
				          },
				          
				]],
				toolbar:[
					{
						text:"添加",
						iconCls:'icon-add',
						handler:function(){
							$("#custtable").edatagrid("addRow");//isnewrecode
						}
					},
					{
						text:"保存",
						iconCls:'icon-add',
						handler:function(){
							//在这里执行密码提交以前的比较工作
							
							$("#custtable").edatagrid("saveRow");//完成添加或者更新
						}
					},
					{
						text:"撤销操作",
						iconCls:'icon-undo',
						handler:function(){
							$("#custtable").edatagrid("cancelRow");
						}
					}
				]
		
			});
		}


		$(function(){
			searchCust("","");
			new uploadPreview({ UpBtn: "up_img", DivShow: "imgdiv", ImgShow: "uimage" });
		});
	</script>
  </body>
</html>
